<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">

function searchBtn() {
	$("#searchBtn").prop("disabled", true);
	
	$("#result").html("로딩중입니다. 잠시만 기다려 주십시오.");
	
	var days = $("#yearSelecter").val() + "-" + $("#monthSelecter").val() + "-01";
	
	$.ajax({
		url: "tempDayReport.ga",
		type: "post",
		dataType: "html",
		data: {
			days: days
		},
		success: function(data) {
			$("#result").html(data);
			$("#searchBtn").prop("disabled", false);
		},
		error: function() {
			$("#result").html("");
			alert("오류가 발생하였습니다. 다시 시도하여 주십시오.");
			$("#searchBtn").prop("disabled", false);
		}
	});
}


</script>

</head>
<body>

<%
Date date = new Date();
int nowYear = date.getYear( ) + 1900;
int minYear = 2013;
%>

<h2>임시 리포트</h2>


<table width="100%">
        <tr>
            <td>
                &nbsp;&nbsp; 월별 검색 &nbsp;
                <select id="yearSelecter">
                    <%
                    for ( int i = minYear; i <= nowYear; i++ ) {
                    	if ( i == nowYear ) {
                    		%>
                    		<option value="<%= i %>" selected><%= i %></option>
                    		<%
                    	} else {
                    	    %>
                    	    <option value="<%= i %>"><%= i %></option>
                    	    <%
                        }
                    }
                    %>
                </select> 년 &nbsp;&nbsp;
                
                <select id="monthSelecter">
                    <%
                    for ( int i = 1; i <= 12; i++ ) {
                    	if ( i == date.getMonth( ) + 1 ) {
                    		%>
                    		<option value="<%= i %>" selected><%= i %></option>
                    		<%
                    	} else {
                    		%>
                    		<option value="<%= i %>"><%= i %></option>
                    		<%
                    	}
                    }
                    %>
                </select> 월 &nbsp;&nbsp;
                <input type="button" id="searchBtn" value="검색" onclick="searchBtn()" style="width:80px;height:26px;"/>
            </td>
            
        </tr>
    </table>

<br/><br/>

<div id="result"></div>


</body>
</html>